﻿#include "Config.h"
#include "tool.h"

Config::Config()
{
    memset(&confVar,0,sizeof(confVar));
    confName = "FR.ini";
}

Config::~Config()
{
}

QVariant Config::getConfig(const char *set, const char *key){
    QVariant ret = configIni->value(QString("/%0/%1").arg(set).arg(key));
    // retInfo(QString("getConfig %0 %1 ret [%2]").arg(set).arg(key).arg(ret.toString()));
    return ret;
}

QVariant Config::getConfVar(const char *key){
    return getConfig("CONF",key);
}

QVariant Config::getUiVar(const char *key){
    return getConfig("UI",key);
}

QVariant Config::getSetupVar(const char *key){
    return getConfig("SETUP",key);
}

QVariant Config::getShellVar(const char *key){
    return getConfig("SHELL",key);
}

QVariant Config::getUimVar(const char *key){
    return getConfig("UIM",key);
}

void Config::setConfName(const QString name){
    confName = name;
}

void Config::readConfig(void)
{
    retInfo(confName);

    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    // CONF
    qStrToCstr(getConfVar("Title").toString(),
               confVar.Title,sizeof(confVar.Title));
    confVar.Start = qStrToInt(getConfVar("Start").toString());
    confVar.MouseWheelStep = qStrToInt(getConfVar("MouseWheelStep").toString());
    confVar.MouseMoveStep = qStrToInt(getConfVar("MouseMoveStep").toString());
    confVar.WindowMax = qStrToInt(getConfVar("WindowMax").toString());
    confVar.WindowClose = qStrToInt(getConfVar("WindowClose").toString());
    confVar.WindowWidth = qStrToInt(getConfVar("WindowWidth").toString());
    confVar.WindowHeight = qStrToInt(getConfVar("WindowSetupWidth").toString());
    confVar.WindowSetupWidth = qStrToInt(getConfVar("WindowSetupWidth").toString());
    confVar.WindowSetupHeight = qStrToInt(getConfVar("WindowSetupHeight").toString());
    confVar.Debug = qStrToInt(getConfVar("Debug").toString());
    // UI
    uiVar.MessageBoxSize = qStrToInt(getUiVar("MessageBoxSize").toString());
    uiVar.PushButtonPressTimer = qStrToInt(getUiVar("PushButtonPressTimer").toString());
    uiVar.PushButtonSetupSize = qStrToInt(getUiVar("PushButtonSetupSize").toString());
    uiVar.PushButtonSetupWidth = qStrToInt(getUiVar("PushButtonSetupWidth").toString());
    uiVar.PushButtonSetupHeight = qStrToInt(getUiVar("PushButtonSetupHeight").toString());
    qStrToCstr(getUiVar("PushButtonSetupText").toString(),uiVar.PushButtonSetupText,sizeof(uiVar.PushButtonSetupText));
    uiVar.PushButtonExitSize = qStrToInt(getUiVar("PushButtonExitSize").toString());
    uiVar.PushButtonExitWidth = qStrToInt(getUiVar("PushButtonExitWidth").toString());
    uiVar.PushButtonExitHeight = qStrToInt(getUiVar("PushButtonExitHeight").toString());
    qStrToCstr(getUiVar("PushButtonExitText").toString(),uiVar.PushButtonExitText,sizeof(uiVar.PushButtonExitText));
    uiVar.PushButtonHaltSize = qStrToInt(getUiVar("PushButtonHaltSize").toString());
    uiVar.PushButtonHaltWidth = qStrToInt(getUiVar("PushButtonHaltWidth").toString());
    uiVar.PushButtonHaltHeight = qStrToInt(getUiVar("PushButtonHaltHeight").toString());
    qStrToCstr(getUiVar("PushButtonHaltText").toString(),uiVar.PushButtonHaltText,sizeof(uiVar.PushButtonHaltText));
    //
    uiVar.LabelPositionSize = qStrToInt(getUiVar("LabelPositionSize").toString());
    uiVar.LabelPositionWidth = qStrToInt(getUiVar("LabelPositionWidth").toString());
    uiVar.LabelPositionHeight = qStrToInt(getUiVar("LabelPositionHeight").toString());
    qStrToCstr(getUiVar("LabelPositionText").toString(),uiVar.LabelPositionText,sizeof(uiVar.LabelPositionText));
    //
    uiVar.PushButtonForBackMoveInSize = qStrToInt(getUiVar("PushButtonForBackMoveInSize").toString());
    uiVar.PushButtonForBackMoveInWidth = qStrToInt(getUiVar("PushButtonForBackMoveInWidth").toString());
    uiVar.PushButtonForBackMoveInHeight = qStrToInt(getUiVar("PushButtonForBackMoveInHeight").toString());
    qStrToCstr(getUiVar("PushButtonForBackMoveInText").toString(),uiVar.PushButtonForBackMoveInText,sizeof(uiVar.PushButtonForBackMoveInText));
    uiVar.PushButtonForBackMoveOutSize = qStrToInt(getUiVar("PushButtonForBackMoveOutSize").toString());
    uiVar.PushButtonForBackMoveOutWidth = qStrToInt(getUiVar("PushButtonForBackMoveOutWidth").toString());
    uiVar.PushButtonForBackMoveOutHeight = qStrToInt(getUiVar("PushButtonForBackMoveOutHeight").toString());
    qStrToCstr(getUiVar("PushButtonForBackMoveOutText").toString(),uiVar.PushButtonForBackMoveOutText,sizeof(uiVar.PushButtonForBackMoveOutText));
    uiVar.PushButtonForBackResetSize = qStrToInt(getUiVar("PushButtonForBackResetSize").toString());
    uiVar.PushButtonForBackResetWidth = qStrToInt(getUiVar("PushButtonForBackResetWidth").toString());
    uiVar.PushButtonForBackResetHeight = qStrToInt(getUiVar("PushButtonForBackResetHeight").toString());
    qStrToCstr(getUiVar("PushButtonForBackResetText").toString(),uiVar.PushButtonForBackResetText,sizeof(uiVar.PushButtonForBackResetText));
    uiVar.PushButtonForBackUpSize = qStrToInt(getUiVar("PushButtonForBackUpSize").toString());
    uiVar.PushButtonForBackUpWidth = qStrToInt(getUiVar("PushButtonForBackUpWidth").toString());
    uiVar.PushButtonForBackUpHeight = qStrToInt(getUiVar("PushButtonForBackUpHeight").toString());
    qStrToCstr(getUiVar("PushButtonForBackUpText").toString(),uiVar.PushButtonForBackUpText,sizeof(uiVar.PushButtonForBackUpText));
    uiVar.PushButtonForBackDownSize = qStrToInt(getUiVar("PushButtonForBackDownSize").toString());
    uiVar.PushButtonForBackDownWidth = qStrToInt(getUiVar("PushButtonForBackDownWidth").toString());
    uiVar.PushButtonForBackDownHeight = qStrToInt(getUiVar("PushButtonForBackDownHeight").toString());
    qStrToCstr(getUiVar("PushButtonForBackDownText").toString(),uiVar.PushButtonForBackDownText,sizeof(uiVar.PushButtonForBackDownText));
    uiVar.PushButtonPushMoveDownSize = qStrToInt(getUiVar("PushButtonPushMoveDownSize").toString());
    uiVar.PushButtonPushMoveDownWidth = qStrToInt(getUiVar("PushButtonPushMoveDownWidth").toString());
    uiVar.PushButtonPushMoveDownHeight = qStrToInt(getUiVar("PushButtonPushMoveDownHeight").toString());
    qStrToCstr(getUiVar("PushButtonPushMoveDownText").toString(),uiVar.PushButtonPushMoveDownText,sizeof(uiVar.PushButtonPushMoveDownText));
    uiVar.PushButtonPushMoveUpSize = qStrToInt(getUiVar("PushButtonPushMoveUpSize").toString());
    uiVar.PushButtonPushMoveUpWidth = qStrToInt(getUiVar("PushButtonPushMoveUpWidth").toString());
    uiVar.PushButtonPushMoveUpHeight = qStrToInt(getUiVar("PushButtonPushMoveUpHeight").toString());
    qStrToCstr(getUiVar("PushButtonPushMoveUpText").toString(),uiVar.PushButtonPushMoveUpText,sizeof(uiVar.PushButtonPushMoveUpText));
    uiVar.PushButtonPushMoveResetSize = qStrToInt(getUiVar("PushButtonPushMoveResetSize").toString());
    uiVar.PushButtonPushMoveResetWidth = qStrToInt(getUiVar("PushButtonPushMoveResetWidth").toString());
    uiVar.PushButtonPushMoveResetHeight = qStrToInt(getUiVar("PushButtonPushMoveResetHeight").toString());
    qStrToCstr(getUiVar("PushButtonPushMoveResetText").toString(),uiVar.PushButtonPushMoveResetText,sizeof(uiVar.PushButtonPushMoveResetText));
    //
    uiVar.LabelMoveSize = qStrToInt(getUiVar("LabelMoveSize").toString());
    uiVar.LabelMoveWidth = qStrToInt(getUiVar("LabelMoveWidth").toString());
    uiVar.LabelMoveHeight = qStrToInt(getUiVar("PushButtonLeftFastHeight").toString());
    qStrToCstr(getUiVar("LabelMoveText").toString(),uiVar.LabelMoveText,sizeof(uiVar.LabelMoveText));
    //
    uiVar.PushButtonLeftFastSize = qStrToInt(getUiVar("PushButtonLeftFastSize").toString());
    uiVar.PushButtonLeftFastWidth = qStrToInt(getUiVar("PushButtonLeftFastWidth").toString());
    uiVar.PushButtonLeftFastHeight = qStrToInt(getUiVar("PushButtonLeftFastHeight").toString());
    qStrToCstr(getUiVar("PushButtonLeftFastText").toString(),uiVar.PushButtonLeftFastText,sizeof(uiVar.PushButtonLeftFastText));
    uiVar.PushButtonRightFastSize = qStrToInt(getUiVar("PushButtonRightFastSize").toString());
    uiVar.PushButtonRightFastWidth = qStrToInt(getUiVar("PushButtonRightFastWidth").toString());
    uiVar.PushButtonRightFastHeight = qStrToInt(getUiVar("PushButtonRightFastHeight").toString());
    qStrToCstr(getUiVar("PushButtonRightFastText").toString(),uiVar.PushButtonRightFastText,sizeof(uiVar.PushButtonRightFastText));
    uiVar.PushButtonLeftMoveSize = qStrToInt(getUiVar("PushButtonLeftMoveSize").toString());
    uiVar.PushButtonLeftMoveWidth = qStrToInt(getUiVar("PushButtonLeftMoveWidth").toString());
    uiVar.PushButtonLeftMoveHeight = qStrToInt(getUiVar("PushButtonLeftMoveHeight").toString());
    qStrToCstr(getUiVar("PushButtonLeftMoveText").toString(),uiVar.PushButtonLeftMoveText,sizeof(uiVar.PushButtonLeftMoveText));
    uiVar.PushButtonRightMoveSize = qStrToInt(getUiVar("PushButtonRightMoveSize").toString());
    uiVar.PushButtonRightMoveWidth = qStrToInt(getUiVar("PushButtonRightMoveWidth").toString());
    uiVar.PushButtonRightMoveHeight = qStrToInt(getUiVar("PushButtonRightMoveHeight").toString());
    qStrToCstr(getUiVar("PushButtonRightMoveText").toString(),uiVar.PushButtonRightMoveText,sizeof(uiVar.PushButtonRightMoveText));
    //SETUP
    //LEFT
    qStrToCstr(getSetupVar("LabelLeftTitleText").toString(),setupVar.LabelLeftTitleText,sizeof(setupVar.LabelLeftTitleText));
    setupVar.LabelLeftTitleSize = qStrToInt(getSetupVar("LabelLeftTitleSize").toString());
    setupVar.LabelLeftTitleWidth = qStrToInt(getSetupVar("LabelLeftTitleWidth").toString());
    setupVar.LabelLeftTitleHeight = qStrToInt(getSetupVar("LabelLeftTitleHeight").toString());
    setupVar.SpinBoxLeftValueSize = qStrToInt(getSetupVar("SpinBoxLeftValueSize").toString());
    setupVar.SpinBoxLeftValueWidth = qStrToInt(getSetupVar("SpinBoxLeftValueWidth").toString());
    setupVar.SpinBoxLeftValueHeight = qStrToInt(getSetupVar("SpinBoxLeftValueHeight").toString());
    setupVar.PushButtonLeftAddSize = qStrToInt(getSetupVar("PushButtonLeftAddSize").toString());
    setupVar.PushButtonLeftAddWidth = qStrToInt(getSetupVar("PushButtonLeftAddWidth").toString());
    setupVar.PushButtonLeftAddHeight = qStrToInt(getSetupVar("PushButtonLeftAddHeight").toString());
    setupVar.PushButtonLeftDecSize = qStrToInt(getSetupVar("PushButtonLeftDecSize").toString());
    setupVar.PushButtonLeftDecWidth = qStrToInt(getSetupVar("PushButtonLeftDecWidth").toString());
    setupVar.PushButtonLeftDecHeight = qStrToInt(getSetupVar("PushButtonLeftDecHeight").toString());
    //RIGHT
    qStrToCstr(getSetupVar("LabelRightTitleText").toString(),setupVar.LabelRightTitleText,sizeof(setupVar.LabelRightTitleText));
    setupVar.LabelRightTitleSize = qStrToInt(getSetupVar("LabelRightTitleSize").toString());
    setupVar.LabelRightTitleWidth = qStrToInt(getSetupVar("LabelRightTitleWidth").toString());
    setupVar.LabelRightTitleHeight = qStrToInt(getSetupVar("LabelRightTitleHeight").toString());
    setupVar.SpinBoxRightValueSize = qStrToInt(getSetupVar("SpinBoxRightValueSize").toString());
    setupVar.SpinBoxRightValueWidth = qStrToInt(getSetupVar("SpinBoxRightValueWidth").toString());
    setupVar.SpinBoxRightValueHeight = qStrToInt(getSetupVar("SpinBoxRightValueHeight").toString());
    setupVar.PushButtonRightAddSize = qStrToInt(getSetupVar("PushButtonRightAddSize").toString());
    setupVar.PushButtonRightAddWidth = qStrToInt(getSetupVar("PushButtonRightAddWidth").toString());
    setupVar.PushButtonRightAddHeight = qStrToInt(getSetupVar("PushButtonRightAddHeight").toString());
    setupVar.PushButtonRightDecSize = qStrToInt(getSetupVar("PushButtonRightDecSize").toString());
    setupVar.PushButtonRightDecWidth = qStrToInt(getSetupVar("PushButtonRightDecWidth").toString());
    setupVar.PushButtonRightDecHeight = qStrToInt(getSetupVar("PushButtonRightDecHeight").toString());
    //SLOW
    qStrToCstr(getSetupVar("LabelSlowTitleText").toString(),setupVar.LabelSlowTitleText,sizeof(setupVar.LabelSlowTitleText));
    setupVar.LabelSlowTitleSize = qStrToInt(getSetupVar("LabelSlowTitleSize").toString());
    setupVar.LabelSlowTitleWidth = qStrToInt(getSetupVar("LabelSlowTitleWidth").toString());
    setupVar.LabelSlowTitleHeight = qStrToInt(getSetupVar("LabelSlowTitleHeight").toString());
    setupVar.SpinBoxSlowValueSize = qStrToInt(getSetupVar("SpinBoxSlowValueSize").toString());
    setupVar.SpinBoxSlowValueWidth = qStrToInt(getSetupVar("SpinBoxSlowValueWidth").toString());
    setupVar.SpinBoxSlowValueHeight = qStrToInt(getSetupVar("SpinBoxSlowValueHeight").toString());
    setupVar.PushButtonSlowAddSize = qStrToInt(getSetupVar("PushButtonSlowAddSize").toString());
    setupVar.PushButtonSlowAddWidth = qStrToInt(getSetupVar("PushButtonSlowAddWidth").toString());
    setupVar.PushButtonSlowAddHeight = qStrToInt(getSetupVar("PushButtonSlowAddHeight").toString());
    setupVar.PushButtonSlowDecSize = qStrToInt(getSetupVar("PushButtonSlowDecSize").toString());
    setupVar.PushButtonSlowDecWidth = qStrToInt(getSetupVar("PushButtonSlowDecWidth").toString());
    setupVar.PushButtonSlowDecHeight = qStrToInt(getSetupVar("PushButtonSlowDecHeight").toString());
    //FAST
    qStrToCstr(getSetupVar("LabelFastTitleText").toString(),setupVar.LabelFastTitleText,sizeof(setupVar.LabelFastTitleText));
    setupVar.LabelFastTitleSize = qStrToInt(getSetupVar("LabelFastTitleSize").toString());
    setupVar.LabelFastTitleWidth = qStrToInt(getSetupVar("LabelFastTitleWidth").toString());
    setupVar.LabelFastTitleHeight = qStrToInt(getSetupVar("LabelFastTitleHeight").toString());
    setupVar.SpinBoxFastValueSize = qStrToInt(getSetupVar("SpinBoxFastValueSize").toString());
    setupVar.SpinBoxFastValueWidth = qStrToInt(getSetupVar("SpinBoxFastValueWidth").toString());
    setupVar.SpinBoxFastValueHeight = qStrToInt(getSetupVar("SpinBoxFastValueHeight").toString());
    setupVar.PushButtonFastAddSize = qStrToInt(getSetupVar("PushButtonFastAddSize").toString());
    setupVar.PushButtonFastAddWidth = qStrToInt(getSetupVar("PushButtonFastAddWidth").toString());
    setupVar.PushButtonFastAddHeight = qStrToInt(getSetupVar("PushButtonFastAddHeight").toString());
    setupVar.PushButtonFastDecSize = qStrToInt(getSetupVar("PushButtonFastDecSize").toString());
    setupVar.PushButtonFastDecWidth = qStrToInt(getSetupVar("PushButtonFastDecWidth").toString());
    setupVar.PushButtonFastDecHeight = qStrToInt(getSetupVar("PushButtonFastDecHeight").toString());
    //SAVE/CANCEL
    qStrToCstr(getSetupVar("PushButtonSaveText").toString(),setupVar.PushButtonSaveText,sizeof(setupVar.PushButtonSaveText));
    setupVar.PushButtonSaveSize = qStrToInt(getSetupVar("PushButtonSaveSize").toString());
    setupVar.PushButtonSaveWidth = qStrToInt(getSetupVar("PushButtonSaveWidth").toString());
    setupVar.PushButtonSaveHeight = qStrToInt(getSetupVar("PushButtonSaveHeight").toString());
    qStrToCstr(getSetupVar("PushButtonCancelText").toString(),setupVar.PushButtonCancelText,sizeof(setupVar.PushButtonCancelText));
    setupVar.PushButtonCancelSize = qStrToInt(getSetupVar("PushButtonCancelSize").toString());
    setupVar.PushButtonCancelWidth = qStrToInt(getSetupVar("PushButtonCancelWidth").toString());
    setupVar.PushButtonCancelHeight = qStrToInt(getSetupVar("PushButtonCancelHeight").toString());
    //SHELL
    qStrToCstr(getShellVar("LabelShell1").toString(),shellVar.LabelShell1,sizeof(shellVar.LabelShell1));
    qStrToCstr(getShellVar("LabelShell2").toString(),shellVar.LabelShell2,sizeof(shellVar.LabelShell2));
    qStrToCstr(getShellVar("SpinBoxShell").toString(),shellVar.SpinBoxShell,sizeof(shellVar.SpinBoxShell));
    qStrToCstr(getShellVar("PushButtonShellDisabled").toString(),shellVar.PushButtonShellDisabled,sizeof(shellVar.PushButtonShellDisabled));
    qStrToCstr(getShellVar("PushButtonShell1").toString(),shellVar.PushButtonShell1,sizeof(shellVar.PushButtonShell1));
    qStrToCstr(getShellVar("PushButtonShellHover1").toString(),shellVar.PushButtonShellHover1,sizeof(shellVar.PushButtonShellHover1));
    qStrToCstr(getShellVar("PushButtonShellPressed1").toString(),shellVar.PushButtonShellPressed1,sizeof(shellVar.PushButtonShellPressed1));
    qStrToCstr(getShellVar("PushButtonShell2").toString(),shellVar.PushButtonShell2,sizeof(shellVar.PushButtonShell2));
    qStrToCstr(getShellVar("PushButtonShellHover2").toString(),shellVar.PushButtonShellHover2,sizeof(shellVar.PushButtonShellHover1));
    qStrToCstr(getShellVar("PushButtonShellPressed2").toString(),shellVar.PushButtonShellPressed2,sizeof(shellVar.PushButtonShellPressed2));
    qStrToCstr(getShellVar("PushButtonShell3").toString(),shellVar.PushButtonShell3,sizeof(shellVar.PushButtonShell3));
    qStrToCstr(getShellVar("PushButtonShellPressed3").toString(),shellVar.PushButtonShellPressed3,sizeof(shellVar.PushButtonShellPressed3));
    //UIM
    uimVar.UsbPort = qStrToInt(getUimVar("UsbPort").toString());
    uimVar.ComPort = qStrToInt(getUimVar("ComPort").toString());
    uimVar.CanTimer = qStrToInt(getUimVar("CanTimer").toString());
    uimVar.CanLeftId = qStrToInt(getUimVar("CanLeftId").toString());
    uimVar.CanLeftOrg = qStrToInt(getUimVar("CanLeftOrg").toString());
    uimVar.CanLeftEncodeState = qStrToInt(getUimVar("CanLeftEncode").toString());
    uimVar.CanLeftOff = qStrToInt(getUimVar("CanLeftOff").toString());
    uimVar.CanLeftRate = qStrToInt(getUimVar("CanLeftRate").toString());
    uimVar.CanLeftStep = qStrToInt(getUimVar("CanLeftStep").toString());
    uimVar.CanLeftSlowStep = qStrToInt(getUimVar("CanLeftSlowStep").toString());
    uimVar.CanLeftRevStep = qStrToInt(getUimVar("CanLeftRevStep").toString());
    uimVar.CanLeftFastRate = qStrToInt(getUimVar("CanLeftFastRate").toString());
    uimVar.CanRightId = qStrToInt(getUimVar("CanRightId").toString());
    uimVar.CanRightOrg = qStrToInt(getUimVar("CanRightOrg").toString());
    uimVar.CanRightEncodeState = qStrToInt(getUimVar("CanRightEncode").toString());
    uimVar.CanRightOff = qStrToInt(getUimVar("CanRightOff").toString());
    uimVar.CanRightRate = qStrToInt(getUimVar("CanRightRate").toString());
    uimVar.CanRightStep = qStrToInt(getUimVar("CanRightStep").toString());
    uimVar.CanRightSlowStep = qStrToInt(getUimVar("CanRightSlowStep").toString());
    uimVar.CanRightRevStep = qStrToInt(getUimVar("CanRightRevStep").toString());
    uimVar.CanRightFastRate = qStrToInt(getUimVar("CanRightFastRate").toString());
    uimVar.CanForBackId = qStrToInt(getUimVar("CanForBackId").toString());
    uimVar.CanForBackEna = qStrToInt(getUimVar("CanForBackEna").toString());
    uimVar.CanForBackOff = qStrToInt(getUimVar("CanForBackOff").toString());
    uimVar.CanForBackMode = qStrToInt(getUimVar("CanForBackMode").toString());
    uimVar.CanForBackRate = qStrToInt(getUimVar("CanForBackRate").toString());
    uimVar.CanForBackFastRate = qStrToInt(getUimVar("CanForBackFastRate").toString());
    uimVar.CanForBackStep = qStrToInt(getUimVar("CanForBackStep").toString());
    uimVar.CanForBackSense1 = qStrToInt(getUimVar("CanForBackSense1").toString());
    uimVar.CanForBackSense2 = qStrToInt(getUimVar("CanForBackSense2").toString());
    uimVar.CanForBackResetRate = qStrToInt(getUimVar("CanForBackResetRate").toString());
    uimVar.CanForBackResetStep = qStrToInt(getUimVar("CanForBackResetStep").toString());
    uimVar.CanForBackLimitMin = qStrToInt(getUimVar("CanForBackLimitMin").toString());
    uimVar.CanForBackLimitMax = qStrToInt(getUimVar("CanForBackLimitMax").toString());
    uimVar.CanForBackSetIn = qStrToInt(getUimVar("CanForBackSetIn").toString());
    uimVar.CanForBackSetOut = qStrToInt(getUimVar("CanForBackSetOut").toString());
    uimVar.CanPushId = qStrToInt(getUimVar("CanPushId").toString());
    uimVar.CanPushEna = qStrToInt(getUimVar("CanPushEna").toString());
    uimVar.CanPushOff = qStrToInt(getUimVar("CanPushOff").toString());
    uimVar.CanPushRate = qStrToInt(getUimVar("CanPushRate").toString());
    uimVar.CanPushLimit = qStrToInt(getUimVar("CanPushLimit").toString());
    uimVar.CanPushMode = qStrToInt(getUimVar("CanPushMode").toString());
    uimVar.CanPushDown = qStrToInt(getUimVar("CanPushDown").toString());
    uimVar.CanPushUp = qStrToInt(getUimVar("CanPushUp").toString());
    uimVar.CanPushSense1 = qStrToInt(getUimVar("CanPushSense1").toString());
    uimVar.CanPushSense2 = qStrToInt(getUimVar("CanPushSense2").toString());
    uimVar.CanPushResetRate = qStrToInt(getUimVar("CanPushResetRate").toString());
    uimVar.CanPushResetStep = qStrToInt(getUimVar("CanPushResetStep").toString());

    delete configIni;
}

void Config::saveConfig(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    delete configIni;
}

void Config::saveUim(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue("/UIM/CanLeftRate",QString("%0").arg(uimVar.CanLeftRate));
    configIni->setValue("/UIM/CanRightRate",QString("%0").arg(uimVar.CanRightRate));
    configIni->setValue("/UIM/CanLeftFastRate",QString("%0").arg(uimVar.CanLeftFastRate));
    configIni->setValue("/UIM/CanRightFastRate",QString("%0").arg(uimVar.CanRightFastRate));
    configIni->setValue("/UIM/CanLeftStep",QString("%0").arg(uimVar.CanLeftStep));
    configIni->setValue("/UIM/CanRightStep",QString("%0").arg(uimVar.CanRightStep));
    configIni->setValue("/UIM/CanForBackSetIn",QString("%0").arg(uimVar.CanForBackSetIn));
    configIni->setValue("/UIM/CanForBackSetOut",QString("%0").arg(uimVar.CanForBackSetOut));
    configIni->setValue("/UIM/CanPushUp",QString("%0").arg(uimVar.CanPushUp));
    configIni->setValue("/UIM/CanPushDown",QString("%0").arg(uimVar.CanPushDown));

    delete configIni;
}
